<div class="page-content">
    <div class="panel panel-default">
        <div class="panel-heading">
            <ul class="breadcrumb">
                <li><a href="<{:U('Subject/index')}>">课程管理</a> </li>
                <li>
                    <a href="<{:U('Attach/index',array('class_id'=>$class_id))}>">
                        <{$subject_data.subject}>考前准备</a>
                </li>
                <li>添加</li>
            </ul>
        </div>
        <div class="panel-body">
            <style>
            .none {
                display: none
            }
            </style>
            <form enctype="multipart/form-data" class="form-horizontal" action="<{:U('Attach/add')}>" method="post" id="myform">
                <input type="hidden" name="attid" value="<{$data.attid}>">
                <div class="form-group">
                    <label for="input-title" class="col-sm-2 control-label">标题</label>
                    <div class="col-sm-7">
                        <input type="text" style="width:680px" class="form-control" id="atttitle" name="atttitle" value="<{$data.atttitle}>">
                    </div>
                </div>
                <if condition="$class_id">
                    <input type="hidden" name="class_id" value="<{$class_id}>" />
                    <else/>
                    <div class="form-group">
                        <label for="input-title" class="col-sm-2 control-label">相关班级</label>
                        <div class="col-sm-7">
                            <php>$class_list = BoxModel('edu_subject')->get(array('is_show'=>1,'parent_id'=>0),"","order_by");</php>
                            <select name="class_id" class="form-control">
                                <volist name="class_list" id="vo">
                                    <option value="<{$vo.subjectid}>" <if condition="$vo['subjectid'] eq $data['class_id']">selected</if>
                >
                <{$vo.subject}>
                    </option>
                    </volist>
                    </select>
                    </div>
                    </div>
                    </if>
                    <div class="form-group" id="choicebox">
                        <label class="col-sm-2 control-label">经验值</label>
                        <div class="col-sm-7">
                            <input type="text" maxlength="4" name="xuebazi" value="<{$data.xuebazi}>" size="4" needle="needle" class="inline" autocomplete="off">
                            <span class="help-block">获得经验值</span> </div>
                        <div class="col-sm-3"> </div>
                    </div>
                    <div class="form-group" id="choicebox">
                        <label class="col-sm-2 control-label">类型</label>
                        <div class="col-sm-7">
                            <label>
                                <input type="radio" name="type" onclick="show_type()" checked="checked" value="1" /> 视频
                            </label>
                            <label>
                                <input type="radio" name="type" onclick="show_type()" value="2" <if condition="$data['type'] eq 2">checked="checked"</if>
                                />下载</label>
                        </div>
                        <div class="col-sm-3"> </div>
                    </div>
                    <div class="videoDiv none">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">选择视频</label>
                            <div class="col-sm-7"> <a title="选择视频" target="upload_video"  href="<{:U('Subject/upload_video')}>" data-type="modal" class="btn btn-default video-upload">选择视频文件 </a> </div>
                            <div class="col-sm-3"> </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">上传的视频</label>
                            <div class="col-sm-7">
                                <p class="form-control-static">
                                    <input class="form-control" type="text" id="video_url" name="video_url" value="<{$data.video_url}>" />
                                </p>
                            </div>
                            <div class="col-sm-3"> <a onclick="_open_video(this)" src="<{$data.video_info.thumbnail}>" url="<{$data.video_info.m3u8_240}>" title="播放" class="btn btn-default video-upload">播放 </a> </div>
                        </div>
                    </div>
                    <div class="attachDiv none">
                        <div class="form-group">
                            <label for="input-title" class="col-sm-2 control-label">下载路径</label>
                            <div class="col-sm-7">
                                <input type="text" style="width:680px" class="form-control" id="attpath" name="attpath" value="<{$data.attpath}>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="input-title" class="col-sm-2 control-label">文件大小</label>
                            <div class="col-sm-7">
                                <input type="text" class="form-control" id="attsize" name="attsize" value="<{$data.attsize}>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="textarea-content" class="col-sm-2 control-label">软件图片</label>
                            <div class="col-sm-2">
                                <label class="btn btn-primary">上传软件图片
                                    <input id="picname" name="picname" onchange="previewImage(this);check()" class="fileupload hide" type="file" data-target="cover">
                                </label>
                            </div>
                            <div class="col-sm-5">
                                <div class="thumbnail">
                                    <div id="preview">
                                        <if condition="$data['att_img']"> <img src="__Img__/<{$data.att_img}>" width="50" style="display: inline;" /> </if>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="textarea-content" class="col-sm-2 control-label">软件介绍</label>
                            <div class="col-sm-7">
                                <textarea style="width: 680px; height: 400px;" class="form-control" id="textarea-content" name="attext" rows="2">
                                    <{$data[ 'attext']?$data[ 'attext']:$guide_step}>
                                </textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="textarea-content" class="col-sm-2 control-label">激活教程</label>
                            <div class="col-sm-7">
                                <textarea style="width: 680px; height: 400px;" class="form-control" id="textarea-content" name="active_text" rows="2">
                                    <{$data[ 'active_text']?$data[ 'active_text']:$guide_step}>
                                </textarea>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-7" align="center">
                            <button class="btn btn-primary" type="submit">确认保存</button>
                            <input name="att_img" type="hidden" value="<{$data.att_img}>">
                        </div>
                    </div>
            </form>
        </div>
    </div>
</div>
<div class="modal fade" id="modal_video" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">视频播放</h4>
            </div>
            <div class="modal-body">
                <div id="videoPlayer"></div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" charset="utf-8" src="http://cdn.aodianyun.com/lss/ckplayer/player.js"></script>
<script>
function show_type() {
    var type = $("[name='type']:checked").val();
    $(".none").hide();
    if (type == 1) {
        $(".videoDiv").show();
    } else {
        $(".attachDiv").show();
    }
}

show_type();

function _open_video(obj) {
    var url = $(obj).attr("url"); //视频地址
    var image = $(obj).attr("src"); //封面图片
    var w = "560"; //视频宽度
    var h = "368"; //视频高度
    var flashvars = {
        f: 'http://cdn.aodianyun.com/lss/ckplayer/m3u8.swf',
        a: url,
        c: 0,
        s: 4,
        i: image,
        lv: 0
    };
    var params = {
        bgcolor: '#FFF',
        allowFullScreen: true,
        allowScriptAccess: 'always',
        wmode: 'transparent'
    };
    var video = [url];
    CKobject.embed('http://cdn.aodianyun.com/lss/ckplayer/ckplayer.swf', 'videoPlayer', 'ckplayerFlashBox', w, h, false, flashvars, video, params);
    $("#modal_video").modal("show");
}
</script>
<link rel="stylesheet" href="__PUBLIC__/kindeditor-4.1.10/themes/default/default.css" />
<script charset="utf-8" src="__PUBLIC__/kindeditor-4.1.10/kindeditor-min.js"></script>
<script charset="utf-8" src="__PUBLIC__/kindeditor-4.1.10/lang/zh_CN.js"></script>
<script type="text/javascript" src="__PUBLIC__/Js/myup.js"></script>
<script type="text/javascript">
var editor;
KindEditor.ready(function(K) {

    editor = K.create('textarea[name="attext"]', {
        resizeType: 1,
        allowPreviewEmoticons: false,
        allowImageUpload: true,
        formatUploadUrl: false,
        uploadJson: '<php>echo "http://".$_SERVER["HTTP_HOST"];</php><{:api_url("Kindeditor/uploadJson")}>',


    });

    editor = K.create('textarea[name="active_text"]', {
        resizeType: 1,
        allowPreviewEmoticons: false,
        allowImageUpload: true,
        formatUploadUrl: false,
        uploadJson: '<php>echo "http://".$_SERVER["HTTP_HOST"];</php><{:api_url("Kindeditor/uploadJson")}>',

    });


});

$(document).on("videoUploadSuceess",function(e,uploadJson){
	$("[name='video_url']").val(uploadJson.data.location);
})
</script>
